package com.zxy.supplier_system.server.utils.wechat.mini

import org.springframework.web.client.RestTemplate
import org.springframework.web.client.postForObject

private val restTemplate = RestTemplate()

fun WechatMiniProgramHelper.getPhoneNumber(access_token: String, getPhoneNumberCode: String): GetPhoneNumberResponse {
    return restTemplate.postForObject(
        "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=$access_token",
        mapOf("code" to getPhoneNumberCode)
    )
}

data class GetPhoneNumberResponse(
    val phone_info: PhoneInfo?,
    val errcode: Int?,
    val errmsg: String?
)

data class PhoneInfo(
    val phoneNumber: String
)
